import Route from 'react-router/lib/Route'
import {RouterStore} from 'mobx-react-router';
import Home from './components/Home'
import MyWorkPlan from './components/MyWorkPlan'
import AllWorkPlan from './components/AllWorkPlan'
import WorkPlanExchange from './components/WorkPlanExchange'
import PlanModul from './components/PlanModul'
import WorkPlanSharePersonal from './components/WorkPlanSharePersonal'
import WorkPlanSearch from './components/WorkPlanSearch'
import WorkPlanCreate from './public/workPlanCreate/index';
import WorkPlanCreateSingle from './public/workPlanCreateSingle';
import Monitor from './components/Monitor';
import StaffKanban from './components/StaffKanban';
import Test from './components/Test';
// import WorkPlanViewList from './components/WorkPlanViewList';
import WorkPlanViewListNew from './components/WorkPlanViewList/WorkPlanViewListNew';
import OneWeekWorkplan from './components/oneWeekWorkplan';
import {WeaLocaleProvider} from 'ecCom';

const getLocaleLabel = WeaLocaleProvider.getLocaleLabel.bind(this, 'workplan');
const { getLocaleLabelByCode } = WeaLocaleProvider;

// import './lib/wdCalendar_lang_wev8';
import './lib/jquery.calendar_wev8';

import './style/index'

const WpRoute = (
  <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@nkmyp6`} name="wp" breadcrumbName="日程" path="wp" component={Home} onEnter={getLocaleLabel}>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@k759jp`} name="myWorkPlan" breadcrumbName="我的日程" path="myWorkPlan" component={MyWorkPlan}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@8rrjkw`} name="allWorkPlan" breadcrumbName="所有日程" path="allWorkPlan" component={AllWorkPlan}/>
    {/* <Route name="workPlanViewList" breadcrumbName="日程一览表" path="WorkPlanViewList" component={WorkPlanViewList}/> */}
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@z0rud5`} name="workPlanViewList" breadcrumbName="日程一览表" path="WorkPlanViewList" component={WorkPlanViewListNew}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@yr6xxw`} name="oneWeekWorkplan" breadcrumbName="一周预览表" path="oneWeekWorkplan" component={OneWeekWorkplan}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@ddqbtn`} name="workPlanExchange" breadcrumbName="工作交流" path="workPlanExchange" component={WorkPlanExchange}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@tpxi8s`} name="planModul" breadcrumbName="周期日程" path="planModul" component={PlanModul}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@f24z1f`} name="workPlanSharePersonal" breadcrumbName="日程共享" path="workPlanSharePersonal"
           component={WorkPlanSharePersonal}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@r4ycc2`} name="workPlanSearch" breadcrumbName="查询日程" path="workPlanSearch" component={WorkPlanSearch}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@zdv83z`} name="workPlanCreateSingle" breadcrumbName="查询日程单页" path="workPlanCreateSingle"
           component={WorkPlanCreateSingle}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@i2mr6z`} name="monitor" breadcrumbName="日程监控" path="monitor" component={Monitor}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@36tkx9`} name="staffKanban" breadcrumbName="人员看板" path="staffKanban" component={StaffKanban}/>
    <Route ecId={`${this && this.props && this.props.ecId || ''}_Route@xzg1tr`} name="test" breadcrumbName="test" path="test" component={Test}/>
  </Route>
)

import store from './stores/index';
const routing = new RouterStore();
const stores = {...store, routing};

import {Provider} from 'mobx-react';

class WorkPlanCreateProvider extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      reRender: false,
    };
  }
  componentDidMount() {
    // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
    getLocaleLabelByCode('workplan').then(() => this.setState({ reRender: true }));
  }
  render() {
    return <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@e9rwwg`} {...stores}><WorkPlanCreate ecId={`${this && this.props && this.props.ecId || ''}_WorkPlanCreate@qpzlll`} {...this.props}/></Provider>
  }
}

class MyWorkPlanProvider extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      reRender: false,
    };
  }
  componentDidMount() {
    // 多语言加载之后，已经 mount 的组件，需要重新 render 一次，刷新多语言配置。
    getLocaleLabelByCode('workplan').then(() => this.setState({ reRender: true }));
  }
  render() {
    return <Provider ecId={`${this && this.props && this.props.ecId || ''}_Provider@gq61jh`} {...stores}><MyWorkPlan ecId={`${this && this.props && this.props.ecId || ''}_MyWorkPlan@jwtu29`} {...this.props}/></Provider>
  }
}

module.exports = {
  Route: WpRoute,
  store: stores,
  com: {
    WorkPlanCreate: WorkPlanCreateProvider,
    MyWorkPlan: MyWorkPlanProvider
  }
}
